package tiles;

import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;

import view.EViewList;
import view.View;

public class HexTileView extends View {
	
	private Geometry geometry;
	private Material material;	
	
	public HexTileView(EViewList name, Material material) {
		this.material = material;
		this.name = name;
		loadInputListeners();
	}

	@Override
	public void update() {
		HexTileModel fullModel = (HexTileModel) model;
		
		//updateMaterial();
		//updateTexture();
		
		Vector2f vec = fullModel.getCartesianVec();
		
		float x = vec.x; //(float) fullModel.getU();
		float y = vec.y; //(float) fullModel.getV();
		float z = 0.0f; //(float) fullModel.getW();
		
		Vector3f trans = new Vector3f(x, y, z);
		geometry.setLocalTranslation(trans);
	}

	@Override
	public void initView() {
		//MHexTile fullModel = (MHexTile) model;
		String identifier = String.valueOf(modelKey.getValue());
		
		//Create custom tri-mesh for hex tiles
		Mesh hexMesh = new HexMeshBuilder2().buildMesh();
		//geometry = new Geometry(identifier, new Box(1.0f, 1.0f, 1.0f));
		//geometry = new Geometry(identifier, new Quad(1.0f, 1.0f));
		geometry = new Geometry(identifier, hexMesh);
		geometry.setMaterial(material);
		update();		
	}
	
	@Override
	protected void loadInputListeners() {
		// TODO Auto-generated method stub
		
	}

}
